<template>
  <el-dialog :title="`${showText}权限点`" :visible="showDialog" @close="btnCancel">
    <el-form ref="perForm" :model="formData" :rules="rules" label-width="120px">
      <el-form-item label="权限名称" prop="name">
        <el-input v-model="formData.name" style="width:90%" />
      </el-form-item>
      <el-form-item label="权限标识" prop="code">
        <el-input v-model="formData.code" style="width:90%" />
      </el-form-item>
      <el-form-item label="权限描述">
        <el-input v-model="formData.description" style="width:90%" />
      </el-form-item>
      <el-form-item label="开启">
        <el-switch v-model="formData.enVisible" active-value="1" inactive-value="0" />
      </el-form-item>
    </el-form>
    <el-row slot="footer" type="flex" justify="center">
      <el-col :span="6">
        <el-button size="small" type="primary" @click="btnOK">确定</el-button>
        <el-button size="small" @click="btnCancel">取消</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>

<script>
export default {
  props: {
    formData: Object,
    rules: Object,
    showDialog: Boolean,
    showText: String
  },
  methods: {
    btnOK() {
      this.$refs.perForm.validate().then(() => {
        this.$emit('submit', this.formData)// 调用父组件的submit事件，并传入formData
      })
    },
    btnCancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped>
/* 自定义样式 */
</style>
